package com.twopai.twopai.presenter;
import com.twopai.mvpbase.BasePresenter;
import com.twopai.mvpbase.RxScheduler;
import com.twopai.twopai.contact.RunShopFragContract;
import com.twopai.twopai.model.RunShopFragModel;

import okhttp3.RequestBody;

/**
 * Author:twopai
 * Description:
 */
public class RunShopFragPresenter extends BasePresenter<RunShopFragContract.View> implements RunShopFragContract.Presenter {
    private RunShopFragContract.Model model;

    public RunShopFragPresenter() {
        model = new RunShopFragModel();
    }

    @Override
    public void newsList(RequestBody body) {
        if (!isViewAttached()) {
            return;
        }
        model.newsList(body)
                .compose(RxScheduler.Obs_io_main())
                .as(mView.bindAutoDispose())
                .subscribe(bean -> {
                    mView.newsListSuccess(bean);
                }, throwable -> mView.newsListError(throwable));
    }
}
